package com.fei.service;

import com.fei.bean.AdminBean;
import com.fei.mapper.AdminMapper;
import com.fei.mapper.MusicMapper;
import com.fei.mapper.SingerMapper;
import com.fei.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class AdminServiceImpl implements AdminService{

    @Autowired
    AdminMapper adminMapper;
    @Autowired
    MusicMapper musicMapper;
    @Autowired
    SingerMapper singerMapper;
    @Autowired
    UserMapper userMapper;

    @Override
    public AdminBean selectOneNameService(String name) {
        return adminMapper.selectOneName(name);
    }

    @Override
    public List<Integer> selectCount() {
        List<Integer> list = new ArrayList<>();
        Integer num = musicMapper.countMusic();
        Integer num2 = singerMapper.countSinger();
        Integer num3 = userMapper.countUser();
        list.add(num);
        list.add(num2);
        list.add(num3);
        return list;
    }

    @Override
    public Boolean validateNameService(String name) {
        Integer num = adminMapper.validateName(name);
        if(num == 0){
            return true;
        }
        return false;
    }

    @Override
    public Boolean validatePhoneService(String phone) {
        Integer num = adminMapper.validatePhone(phone);
        if(num == 0){
            return true;
        }
        return false;
    }

    @Override
    public int registerAdminService(AdminBean admin) {
        return adminMapper.registerAdmin(admin);
    }


    public AdminMapper getAdminMapper() {
        return adminMapper;
    }

    public void setAdminMapper(AdminMapper adminMapper) {
        this.adminMapper = adminMapper;
    }
}
